/*
 * Project Name:yunjiafen
 * File Name:RequestContext.java
 * Package Name:com.bestapp.yunjiafen.core.util
 * Date:2018年10月22日下午10:02
 * Copyright (c) 2018, bestapp All Rights Reserved.
 *
 */

package com.gitee.xmhzzz.component.spring.cloud.component.dao.context;

import com.gitee.xmhzzz.component.common.dto.PageBase;

import java.util.HashMap;
import java.util.Map;


/**
  * @ClassName
  * @Description
  * @Author wzq
  * @Date 2023/12/15 16:46
  * @Version 1.0
  */
public class PageContext {
    private Map<String, Object> contextParam;

    private PageBase pageBase;

    public PageContext() {
        contextParam = new HashMap<>();
    }


    public PageBase getPageBase() {
        return pageBase;
    }

    public PageContext setPageBase(PageBase pageBase) {
        this.pageBase = pageBase;
        return this;
    }

    public PageContext put(String name, Object value) {
        contextParam.put(name, value);
        return this;
    }

    public Object get(String name) {
        return contextParam.get(name);
    }

    @SuppressWarnings("unchecked")
    public <T> T get(String name, Class<T> clazz) {
        Object value = contextParam.get(name);
        if (value == null) return null;
        if (!clazz.isInstance(value)) {
            return null;
        }
        return (T) value;
    }
}
